<template>
  <view class="select-express-wrap">


    <van-cell
      v-for="(item, index) in expressList"
      :key="index"
      @click="handleSelectExpressCompany(item)"
    >
      <view
        slot="title"
        class="express-name-wrap"
      >
        <!--        <image
                    src="/static/image/express-logo.png"
                    class="express-logo-img"
                ></image>-->
        <view class="express-name">{{ item.name }}</view>
      </view>
    </van-cell>

  </view>
</template>

<script>
const app = getApp()
export default {
  data() {
    return {
      expressList: []
    };
  },
  methods: {
    handleGetExpressCompanyList() {
      app.request({}, '/api/logistics/order/kd_list').then((res) => {
        console.log(res)
        const {
          code,
          data
        } = res

        if (code === 1) {
          this.expressList = data
        }
      })
    },
    handleSelectExpressCompany(item) {
      console.log(item);
      const eventChannel = this.getOpenerEventChannel()

      eventChannel.emit('selectExpress', {
        ...item
      })
      uni.navigateBack()
    }
  },
  onLoad() {
    this.handleGetExpressCompanyList()
  },
}
</script>

<style lang="scss">
.select-express-wrap {
  .express-name-wrap {
    display: flex;
    align-items: center;

    .express-logo-img {
      width: 40rpx;
      height: 40rpx;
      margin-right: 20rpx;
    }

    .express-name {

    }
  }
}
</style>
